<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::get('/', function()
{
	return View::make('hello');
});
Route::get('/', array("as"=>"index","before"=>"check_user","uses"=>"MainController@index"));
//su dung thu vien Sentry de tao tai khoan
Route::get('create-user',function(){
	//dung phuong thuc getUserProvider() de tao du lieu vao bang trong csdl
	$user = Sentry::getUserProvider()->create(array(
		"email"		=>	"thanh061193@gmail.com",
		"password"	=>	"12345",
		"username"	=>	"thanh",
		"first_name"=>	"Van thanh",
		"last_name"	=>	"Nguyen",
		"activated"	=>	1,
		"permissions"=>	array(
			"admin"	=>	1
		)
	));
	return "Insert successfull";
});

Route::get("backend/login",array("as"=>"login_get","before"=>"is_login","uses"=>"AuthController@getLogin"));
Route::post("backend/login",array("as"=>"login_post","before"=>"csrf|is_login","uses"=>"AuthController@postLogin"));
Route::get("backend/logout",array("as"=>"logout_get","before"=>"check_user","uses"=>"AuthController@getLogout"));

//chuc nang them thanh vien
Route::get("backend/list-user",array("as"=>"register_get","before"=>"check_user","uses"=>"AuthController@getRegister"));
Route::get("backend/add-user",array("as"=>"registeruser_get","before"=>"check_user","uses"=>"AuthController@getAddRegister"));
Route::post("backend/add-user",array("as"=>"registeruser_post","before"=>"csrf|check_user","uses"=>"AuthController@postAddRegister"));
Route::get("backend/delete-user/{id}",array("as"=>"deleteuser_post","before"=>"check_access:admin","uses"=>"AuthController@postDeleteUser"))->where(array("id"=>"[0-9]+"));

//tao chuc nang doi mat khau
Route::get("backend/changepassword",array("as"=>"changepassword_get","before"=>"check_user","uses"=>"AuthController@getChangepassword"));
Route::post("backend/changepassword",array("as"=>"changepassword_post","before"=>"check_user","uses"=>"AuthController@postChangepassword"));


//tao chuc nang bai viet
Route::get("backend/create-post",array("as"=>"createPost_get","before"=>"check_user","uses"=>"PostController@getCreateNew"));

Route::post("backend/create-post",array("as"=>"createPost_post","before"=>"crsf|check_user","uses"=>"PostController@postCreateNew"));

Route::get("backend/list-post",array("as"=>"listPost_get","before"=>"check_user","uses"=>"PostController@getListPost"));

Route::get("backend/delete-post-{id}",array("as"=>"delete_get","before"=>"check_user","uses"=>"PostController@getDelete"))->where(array("id"=>"[0-9]+"));

Route::get("backend/edit-post-{id}",array("as"=>"edit_get","before"=>"check_user","uses"=>"PostController@getEdit"))->where(array("id"=>"[0-9]+"));

Route::post("backend/edit-post",array("as"=>"edit_post","before"=>"check_user","uses"=>"PostController@postEdit"));

//tao chuc nang san pham

Route::get("backend/product-create",array("as"=>"create_product_get","before"=>"check_user","uses"=>"ProductController@getCreateProduct"));

Route::post("backend/product-create",array("as"=>"create_product_post","before"=>"check_user","uses"=>"ProductController@postCreateProduct"));

Route::get("backend/product-list",array("as"=>"list_product","before"=>"check_user","uses"=>"ProductController@listProduct"));

Route::get('backend/product-delete-{id}',array('as'=>'delete_product','before'=>'check_user','uses'=>'ProductController@deleteProduct'))->where(array('id'=>'[0-9]+'));

Route::get('backend/product-edit-{id}',array('as'=>'edit_product_get','before'=>'check_user','uses'=>'ProductController@editProductget'))->where(array('id'=>'[0-9]+'));

Route::post('backend/product-edit',array('as'=>'edit_product_post','before'=>'check_user','uses'=>'ProductController@editProductpost'));

//tao chuc nang danh muc san pham

Route::get('backend/cateproduct-list',array('as'=>'list_cateproduct','before'=>'check_user','uses'=>'CateprodctController@listCateProduct'));

Route::get('backend/cateproduct-create',array('as'=>'create_cateproduct_get','before'=>'check_user','uses'=>'CateprodctController@createCateProductget'));

Route::post('backend/cateproduct-create',array('as'=>'create_cateproduct_post','before'=>'check_user','uses'=>'CateprodctController@createCateProductpost'));

Route::get('backend/cateproduct-edit-{id}',array('as'=>'edit_cateproduct_get','before'=>'check_user','uses'=>'CateprodctController@editCateProductget'));

Route::post('backend/cateproduct-edit',array('as'=>'edit_cateproduct_post','before'=>'check_user','uses'=>'CateprodctController@editCateProductpost'));

Route::get('backend/cateproduct-delete-{id}',array('as'=>'delete_cateprodut','before'=>'check_user','uses'=>'CateprodctController@deleteCateproduct'));


//font end
Route::get('fontend/', array("as"=>"indexhome","uses"=>"MainController@indexhome"));
Route::get("fontend/bai-viet",array("as"=>"baiviet_get","uses"=>"PostController@getBaiviet"));
Route::get("fontend/detail-{title}-{id}",array("as"=>"baiviet_detail_get","uses"=>"PostController@getDetail"))->where(array("title"=>"[a-zA-Z0-9._\-]+","id"=>"[0-9]+"));


//cart
Route::get('fontend/add-cart-{id}',array('as'=>'add_cart','uses'=>'MainController@addCart'));

Route::get('fontend/view-cart',array('as'=>'view_cart','uses'=>'MainController@viewCart'));

Route::get('fontend/deleteall-cart',array('as'=>'deleteall_cart','uses'=>'MainController@deleteallCart'));

Route::get('fontend/deleteitem-cart-{id}',array('as'=>'deleteitem_cart','uses'=>'MainController@deleteitemCart'));

Route::post('fontend/update-cart',array('as'=>'update_cart','uses'=>'MainController@updateCart'));

Route::post('fontend/checkout-cart',array('as'=>'checkout_cart','uses'=>'MainController@checkoutCart'));

